Skip to content

fix: prefer DevToolsActivePort websocket path over HTTP discovery in --auto-connect#1218

Open
jin-2-kakaoent wants to merge 3 commits intovercel-labs:mainfrom
hyunjinee:fix/auto-connect-discovery
Open

fix: prefer DevToolsActivePort websocket path over HTTP discovery in --auto-connect#1218
jin-2-kakaoent wants to merge 3 commits intovercel-labs:mainfrom
hyunjinee:fix/auto-connect-discovery

Conversation

@jin-2-kakaoent
Copy link
Copy Markdown
Contributor

@jin-2-kakaoent jin-2-kakaoent commented Apr 12, 2026

Fixes #1210
Fixes #1206

Summary

  • Reverses the discovery order in auto_connect_cdp(): tries the exact WebSocket path from DevToolsActivePort first, falls back to legacy HTTP endpoints (/json/version, /json/list) only on failure
  • Adds verify_ws_endpoint() to validate the WebSocket URL is a live CDP server before returning it
  • Removes redundant synchronous is_port_reachable() TCP probe that blocked the async runtime

Why

On Chrome M144+, --auto-connect triggered two separate remote-debugging permission prompts because legacy HTTP discovery probes (/json/version, /json/list) were attempted before using the exact WebSocket path already available in DevToolsActivePort. Each probe triggered its own permission flow.

Before → After

Before (HTTP first) After (ws_path first)
Discovery order HTTP /json/version/json/list/devtools/browser → exact ws_path exact ws_path → HTTP fallback
Permission prompts 2 (one per discovery method) 1
Connection time ~5s (HTTP timeouts) ~0.2s
Stale URL handling Returns unverified URL Validates via Browser.getVersion handshake

Test plan

  • Unit tests: 3 new tests covering ws_path preference, HTTP fallback, and both-fail scenarios
  • All 625 existing tests pass
  • Real Chrome (M147) with --remote-debugging-port: --auto-connect connects in 0.2s
  • Stale DevToolsActivePort (dead port): clean error instead of hang
  • --cdp mode unaffected
  • close does not kill external Chrome

…--auto-connect

Reverses the discovery order in `auto_connect_cdp()` so the exact
WebSocket path from DevToolsActivePort is tried first, falling back
to legacy HTTP endpoints (`/json/version`, `/json/list`) only when
the direct path fails. This eliminates the duplicate remote-debugging
permission prompts caused by unnecessary HTTP probes on Chrome M144+.

Also adds `verify_ws_endpoint()` to validate the WebSocket URL is a
live CDP server before returning it, preventing stale URLs from being
handed to callers.

Fixes vercel-labs#1210
Fixes vercel-labs#1206
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 12, 2026

@hyunjinee is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants